<?php

namespace App\Http\Controllers\Admin;

use App\Models\Onorder;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CheckController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function __construct()
    {
        view()->share([
            '_checks' => 'am-in',
            '_check' => 'am-active',
        ]);

    }


    public function index()
    {
       return view('admin.check.index');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */


    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $data['type']=$request->type;
        $data['order_no']=$request->order_no;

        $info=Onorder::where($data)->first();
        if(isset($info) && $info->statu==1){
            return back()->with('success','此卷码已被使用');
        }
        if(isset($info) && $info->statu==0 && $request->type==1){
            return redirect('admin/order/onbespeakorder?order_no='.$request->order_no)->with('success','详细信息');
        }
        if(isset($info) && $info->statu==0 && $request->type==0){
            return redirect('admin/order/onpackorder?order_no='.$request->order_no)->with('success','详细信息');
        }
        else{
            return back()->with('success','此卷码不存在');
        }
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function sms(){
        return view('admin.check.sms');


    }
}
